#include "gtest/gtest.h"
#include "../BaseUtil/MyTest.h"
#include "MyVideoTrace.h"
namespace MyVideoTrace {

class Point2DTest: public testing::Test {
protected:
	virtual void SetUp() {
	}

	virtual void TearDown() {
	}
};

TEST_F(Point2DTest, Observers) {
	Point2D pnt(3, 4);

	ASSERT_EQ(3, pnt.getX());
	ASSERT_EQ(4, pnt.getY());
}

TEST_F(Point2DTest, Equality) {
	Point2D pnt1(3, 4);
	Point2DPtr pnt2 = new Point2D(pnt1);
	Point2D pnt3(3, 4);

	ASSERT_TRUE( pnt1 == pnt1 );
	ASSERT_TRUE( *pnt2 == *pnt2 );
	ASSERT_TRUE( pnt3 == pnt3 );

	ASSERT_EQ( pnt1 == *pnt2, *pnt2 == pnt1 );

	ASSERT_TRUE( pnt1 == *pnt2 );
	ASSERT_TRUE( *pnt2 == pnt3 );
	ASSERT_TRUE( pnt1 == pnt3 );

	ASSERT_EQ(3, pnt1.getX());
	ASSERT_EQ(4, pnt1.getY());
}

TEST_F(Point2DTest, Plus) {
	Point2D pnt1(3, 4);
	Point2D pnt2(13, 14);

	ASSERT_EQ( 16, (pnt1 + pnt2).getX() );
	ASSERT_EQ( 18, (pnt1 + pnt2).getY() );

	ASSERT_EQ(3, pnt1.getX());
	ASSERT_EQ(4, pnt1.getY());

	ASSERT_EQ(13, pnt2.getX());
	ASSERT_EQ(14, pnt2.getY());
}

TEST_F(Point2DTest, DivideInt) {
	Point2D pnt1(6, 8);

	ASSERT_EQ( 3, (pnt1 / 2).getX() );
	ASSERT_EQ( 4, (pnt1 / 2).getY() );

	ASSERT_EQ(6, pnt1.getX());
	ASSERT_EQ(8, pnt1.getY());
}

TEST_F(Point2DTest, MultiplyInt) {
	Point2D pnt1(6, 8);

	ASSERT_EQ( 12, (pnt1 * 2).getX() );
	ASSERT_EQ( 16, (pnt1 * 2).getY() );

	ASSERT_EQ(6, pnt1.getX());
	ASSERT_EQ(8, pnt1.getY());
}

}
